php artisan migrate --path=database/migrations/2024_07_09_000000_create_wechat_service_account_addresses_table.php<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWechatServiceAccountAddressesTable extends Migration
{
    public function up()
    {
        Schema::create('wechat_service_account_addresses', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('关联wechat_service_account_users表');
            $table->string('consignee')->comment('收货人');
            $table->string('mobile')->comment('手机号');
            $table->string('province')->comment('省');
            $table->string('city')->comment('市');
            $table->string('district')->nullable()->comment('区');
            $table->string('address')->comment('详细地址');
            $table->boolean('is_default')->default(false)->comment('是否默认地址');
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('wechat_service_account_users')->onDelete('cascade');
        });
    }

    public function down()
    {
        Schema::dropIfExists('wechat_service_account_addresses');
    }
}
